package com.scqzy.shengchunqiang.sword2offer.day05;

/**
 * @Description: 剑指 Offer 11. 旋转数组的最小数字
 * @Author 盛春强
 * @Date 2021/8/12 20:37
 */
public class MinArray {
    public int minArray(int[] numbers) {
        int left = 0;
        int right = numbers.length - 1;
        while (left < right) {
            int mid = (left + right) >> 1;
            if (numbers[right] > numbers[mid]) {
                right = mid;
            } else if (numbers[right] < numbers[mid]) {
                left = mid + 1;
            // 相等往前挪一个
            } else {
                right--;
            }
        }
        return numbers[left];
    }
}
